fix: updating credentials alerts and management patterns#73
Merged
Conversation
238e2dd to
9230f5a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available: n/a
Summary
AWS region auto-detection -- Replaced the hardcoded
REGION = "us-west-2"inconfig.tswith aresolveRegion()function that follows the standard AWS precedence chain:AWS_REGIONenv var →AWS_DEFAULT_REGIONenv var →~/.aws/config [default]profile →us-west-2fallback.Startup config warnings -- Added a
ConfigWarningstoast system that validates AWS configuration on app launch. Performs an async STSGetCallerIdentitycheck to catch expired/invalid credentials and alerts when the region falls back to the default. Toasts are styled with the shared glass-morphism pattern and auto-dismiss (12s for warnings, 20s for errors).Fixed broken credential error handling --
s3Helper.tsandsmHelper.tshade instanceof CredsExpiredAlertin their catch blocks, butCredsExpiredAlertis a React component, not an Error class. Theinstanceofcheck itself threwTypeError: Function has non-object prototype 'undefined', turning every caught AWS error into an uncaught exception. Replaced with a sharedisCredentialError()utility that detects auth failures by error name and HTTP status code.Fixed S3 client stale credentials -- The
S3Clientins3Helper.tswas instantiated once at module load with static credentials. After refreshing~/.aws/credentials, the client still used the original stale creds. Changed to a credentials provider function so the SDK reads fresh credentials on every request.Hardened modal error handling -- Wrapped all async data-fetching
useEffectcalls inImageRequestModal,LoadDataModal, andLoadImageModalwith try/catch. Fixedres !== undefinednull checks (truthy fornull) tores && Array.isArray(res) && res.length > 0to preventnull.map()crashes.Modernized
CredsExpiredAlert-- Rewrote to use the sharedConfigWarnings.csstoast classes instead of inline styles. Added slide-in/out animations, a close (X) button, disabled state during retry, and properly typed props.README overhaul -- Rewrote with features overview, architecture table, usage guides, project structure, configuration reference (including region auto-detection docs), and updated resource links. Removed outdated CloudScape reference.
Files changed
src/config.tsgetConfigWarnings()async validation,isCredentialError()helpersrc/util/s3Helper.tssrc/util/smHelper.tsinstanceof)src/components/alert/ConfigWarnings.tsxsrc/components/alert/ConfigWarnings.csssrc/components/alert/CredsExpiredAlert.tsxsrc/components/modal/ImageRequestModal.tsxsrc/components/modal/LoadDataModal.tsxsrc/components/modal/LoadImageModal.tsxsrc/App.tsx<ConfigWarnings />Checklist
Before you submit a pull request, please make sure you have the following:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.